﻿#include "ListeTransitions.h"
#include "Transition.h"

#include <exception>
#include <stdexcept>

typedef transitionContainer::iterator transIterator;

ListeTransitions::ListeTransitions() {

}

ListeTransitions::~ListeTransitions()
{
	for (transIterator it = transitions.begin(); it != transitions.end(); ++it)
		delete *it;
}

void ListeTransitions::push_back(Transition* transition)
{
	transitions.push_back(transition);
}

Transition* ListeTransitions::operator[](unsigned index) const
{
	
	Transition* tempPtr = nullptr;
	if (index >= 0 && index < transitions.size())
		tempPtr = transitions[index];
	else
		throw std::logic_error("ListeTransitions::operator[](unsigned):\n Index trop grand ou negatif\n");
	return tempPtr;
}

unsigned ListeTransitions::size() const
{
	return transitions.size();
}

transitionContainer::iterator ListeTransitions::begin()
{
	return transitions.begin();
}

const_transItr ListeTransitions::begin() const
{
	return transitions.begin();
}

transitionContainer::iterator ListeTransitions::end()
{
	return transitions.end();
}

const_transItr ListeTransitions::end() const
{
	return transitions.end();
}

transitionContainer::iterator ListeTransitions::erase(transItr it)
{
	return transitions.erase(it);
}
